/*
 * @lc app=leetcode.cn id=2325 lang=typescript
 *
 * [2325] 解密消息
 */

// @lc code=start
function decodeMessage(key: string, message: string): string {
    const replacer: string[] = [];
    for (let i = 0; i < key.length; i++) {
        const element = key[i];
        if (element !== " " && !replacer.includes(element)) {
            replacer.push(element);
        }
    }
    return message
        .split("")
        .map((i) => {
            if (i !== " ") {
                return String.fromCharCode(replacer.indexOf(i) + 97);
            } else {
                return i;
            }
        })
        .join("");
}
// @lc code=end
